Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create system roles by default #17341

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Create system roles by default #17341

wants to merge 10 commits into from

Conversation

hishamco
Copy link
Member

@hishamco hishamco commented Jan 12, 2025

Fixes #17271

@hishamco hishamco marked this pull request as draft January 12, 2025 04:40
@MikeAlhayek
Copy link
Member

@hishamco I know this is a draft. But I think you are missing the ask. Not all these roles are system role. There are currently only 3 system roles. Administration (this name could be changed), Anonymous, and Authorized.

You should inject ISystemRolePrpvider to get a list of the system roles.

In the roles module, create a SystemRolesMigrations file that would read the system roles from the provider and create them using the RoleManager. Then you can remove only these 3 roles from the recipes.

@hishamco
Copy link
Member Author

Thanks it is still a draft, I added the system roles first, then added the rest accidentally

Using the provider is much better, I will react to your feedback

@hishamco
Copy link
Member Author

@MikeAlhayek I didn't see a description there, or shall we make ISystemRoleProvider instead of ISystemRoleNameProvider?

@hishamco hishamco marked this pull request as ready for review January 13, 2025 00:08
@hishamco hishamco requested a review from MikeAlhayek January 13, 2025 00:13
@hishamco
Copy link
Member Author

I tried the PR on a fresh installation and it works fine but I don't know why it fails in Linux

@hishamco hishamco requested a review from MikeAlhayek January 13, 2025 05:29
@@ -33,7 +33,10 @@ public Startup(IShellConfiguration shellConfiguration)
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IUserClaimsProvider, RoleClaimsProvider>();
services.AddDataMigration<RolesMigrations>();

services.AddDataMigration<SystemRolesMigrations>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't need to be groped since they don't depend on each other

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will make no difference

Copy link
Member

@MikeAlhayek MikeAlhayek Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not. But it imply that they depend on each other

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SaaS recipe still has these. pages.recipe.json too but I'm not sure how that's used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too :) but seems used the module for test project to test Assembly attributes if I recall

{
if (await _roleManager.FindByNameAsync(role) is null)
{
await _roleManager.CreateAsync(new Role { RoleName = role });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The descriptions of the roles need to be retained too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already pointed to that in #17341 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create System roles by default
3 participants